package com.lhframework.sms.schedule;

import com.lhframework.sms.api.TimingSmsSender;
import com.lhframework.sms.service.ShortMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Created by lh on 2017/7/28.
 */
//@Component
//public class SmsScheduleTask {
//
//    @Autowired
//    private ShortMessageService shortMessageService;
//    @Autowired
//    private TimingSmsSender timingSmsSender;
//
//    /**
//     * 定时发送短信任务
//     */
//    @Scheduled(fixedRate = 2 * 60 * 1000)
//    public void timingSendSmsTask() {
//        Date now = new Date();
//        shortMessageService.findTimingShortMessages().stream().filter(shortMessage -> shortMessage.getSendTime() != null && shortMessage.getSendTime().before(now))
//                .forEach(shortMessage -> timingSmsSender.send(shortMessage));
//    }
//}
